#!/bin/bash

cd $(dirname $0)

green(){
    echo -e "\033[0;32m$*\033[0m"
}

blue(){
    echo -e "\033[0;34m$*\033[0m"
}

blue "Cleanup"
docker-compose -p quickstart -f file.yml down

blue "Starting file+fluentd-pilot"
docker-compose -p quickstart -f file.yml up -d

host=127.0.0.1

if [ -n "$DOCKER_HOST" ]; then
    host=$(echo $DOCKER_HOST|sed -e 's:^.*//::' -e 's/:.*$//')
fi

if [ -z "$host" ]; then
    echo "Could not detect docker host."
fi

blue "\nCleanup"
#docker-compose -p busybox -f busybox.yml down
docker-compose -p tomcat -f tomcat.yml down

blue "Starting application"
#docker-compose -p busybox -f busybox.yml up -d
docker-compose -p tomcat -f tomcat.yml up -d

pwd=$(pwd)
project=$(basename $pwd)

echo 
green "Start successfully!"
echo

cat << EOF
Now enter the FILE_PATH and after 1 minutes you can see any logs.
EOF
